package com.appwoo.txtws.component;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.appwoo.txtws.bean.LocationBean;
import java.util.ArrayList;

public class LocationHelper extends SQLiteOpenHelper
{
  private static final int version = 7;
  private SQLiteDatabase mdb = null;

  public LocationHelper(Context paramContext)
  {
    super(paramContext, "db_location", null, 7);
  }

  public int delData()
  {
    int i = -1;
    if (this.mdb == null)
      this.mdb = getWritableDatabase();
    try
    {
      int j = this.mdb.delete("t_location", "isupload = 'y'", null);
      i = j;
      return i;
    }
    catch (Exception localException)
    {
      Logger.e("xjf", "location delData:" + localException.toString());
      return i;
    }
    finally
    {
      if (this.mdb != null)
      {
        this.mdb.close();
        this.mdb = null;
      }
    }
  }

  // ERROR //
  public void insertLocation(String paramString1, String paramString2, String paramString3, String paramString4)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   4: ifnonnull +116 -> 120
    //   7: aload_0
    //   8: aload_0
    //   9: invokevirtual 26	com/appwoo/txtws/component/LocationHelper:getWritableDatabase	()Landroid/database/sqlite/SQLiteDatabase;
    //   12: putfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   15: new 68	android/content/ContentValues
    //   18: dup
    //   19: invokespecial 70	android/content/ContentValues:<init>	()V
    //   22: astore 5
    //   24: aload 5
    //   26: ldc 72
    //   28: aload_1
    //   29: invokevirtual 75	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   32: aload 5
    //   34: ldc 77
    //   36: aload_2
    //   37: invokevirtual 75	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   40: aload 5
    //   42: ldc 79
    //   44: aload_3
    //   45: invokevirtual 75	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   48: aload 5
    //   50: ldc 81
    //   52: aload 4
    //   54: invokevirtual 75	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   57: aload 5
    //   59: ldc 83
    //   61: ldc 85
    //   63: invokevirtual 75	android/content/ContentValues:put	(Ljava/lang/String;Ljava/lang/String;)V
    //   66: ldc 87
    //   68: new 44	java/lang/StringBuilder
    //   71: dup
    //   72: ldc 89
    //   74: invokespecial 49	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   77: aload_3
    //   78: invokevirtual 57	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   81: invokevirtual 58	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   84: invokestatic 92	com/appwoo/txtws/component/Logger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   87: aload_0
    //   88: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   91: ldc 28
    //   93: aconst_null
    //   94: aload 5
    //   96: invokevirtual 96	android/database/sqlite/SQLiteDatabase:insertOrThrow	(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;)J
    //   99: pop2
    //   100: aload_0
    //   101: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   104: ifnull +15 -> 119
    //   107: aload_0
    //   108: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   111: invokevirtual 40	android/database/sqlite/SQLiteDatabase:close	()V
    //   114: aload_0
    //   115: aconst_null
    //   116: putfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   119: return
    //   120: aload_0
    //   121: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   124: invokevirtual 40	android/database/sqlite/SQLiteDatabase:close	()V
    //   127: aload_0
    //   128: aload_0
    //   129: invokevirtual 26	com/appwoo/txtws/component/LocationHelper:getWritableDatabase	()Landroid/database/sqlite/SQLiteDatabase;
    //   132: putfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   135: goto -120 -> 15
    //   138: astore 7
    //   140: aload_0
    //   141: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   144: ifnull -25 -> 119
    //   147: aload_0
    //   148: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   151: invokevirtual 40	android/database/sqlite/SQLiteDatabase:close	()V
    //   154: aload_0
    //   155: aconst_null
    //   156: putfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   159: return
    //   160: astore 6
    //   162: aload_0
    //   163: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   166: ifnull +15 -> 181
    //   169: aload_0
    //   170: getfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   173: invokevirtual 40	android/database/sqlite/SQLiteDatabase:close	()V
    //   176: aload_0
    //   177: aconst_null
    //   178: putfield 18	com/appwoo/txtws/component/LocationHelper:mdb	Landroid/database/sqlite/SQLiteDatabase;
    //   181: aload 6
    //   183: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   66	100	138	java/lang/Exception
    //   66	100	160	finally
  }

  public void onCreate(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS t_location(id INTEGER PRIMARY KEY AUTOINCREMENT, lng TEXT, lat TEXT, address TEXT, time TEXT, isupload TEXT );");
  }

  public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
  {
    try
    {
      paramSQLiteDatabase.execSQL("drop table t_location");
      paramSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS t_location(id INTEGER PRIMARY KEY AUTOINCREMENT, lng TEXT, lat TEXT, address TEXT, time TEXT, isupload TEXT );");
      return;
    }
    catch (Exception localException)
    {
      while (true)
        Logger.e("System.out", "onUpgrade Location--" + localException.toString());
    }
  }

  public ArrayList<LocationBean> queryLocation()
  {
    if ((this.mdb == null) || (!this.mdb.isOpen()))
      this.mdb = getReadableDatabase();
    ArrayList localArrayList = new ArrayList();
    try
    {
      Cursor localCursor = this.mdb.query("t_location", null, "isupload = 'n'", null, null, null, null);
      while (true)
      {
        if (!localCursor.moveToNext())
        {
          localCursor.close();
          return localArrayList;
        }
        LocationBean localLocationBean = new LocationBean();
        localLocationBean.setId(localCursor.getString(localCursor.getColumnIndexOrThrow("id")));
        localLocationBean.setLng(localCursor.getString(localCursor.getColumnIndexOrThrow("lng")));
        localLocationBean.setLat(localCursor.getString(localCursor.getColumnIndexOrThrow("lat")));
        localLocationBean.setAddress(localCursor.getString(localCursor.getColumnIndexOrThrow("address")));
        localLocationBean.setTime(localCursor.getString(localCursor.getColumnIndexOrThrow("time")));
        localLocationBean.setIsUpload(localCursor.getString(localCursor.getColumnIndexOrThrow("isupload")));
        localArrayList.add(localLocationBean);
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return localArrayList;
    }
    finally
    {
      if (this.mdb != null)
        this.mdb.close();
    }
  }

  public void updateLocation(String paramString)
  {
    if (this.mdb == null)
      this.mdb = getWritableDatabase();
    while (true)
    {
      new ContentValues().put("isupload", "y");
      try
      {
        String str = "update t_location set isupload = 'y' where id = " + paramString;
        this.mdb.execSQL(str);
        return;
        this.mdb.close();
        this.mdb = getWritableDatabase();
      }
      catch (Exception localException)
      {
        Logger.e("xjf", "updateLocation:" + localException.toString());
        return;
      }
      finally
      {
        if (this.mdb != null)
        {
          this.mdb.close();
          this.mdb = null;
        }
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.component.LocationHelper
 * JD-Core Version:    0.6.2
 */